package com.kainitram.library;

import android.view.View;
import android.widget.Toast;

/**
 * Class whic subscribe validation result.
 * @author Mino
 *
 */
public class ValidationResult {

	private String errorMessage;
	private View viewWhichRequestFocus;
	
	public ValidationResult()
	{
	}
	
	
	public static ValidationResult getValidResult()
	{
		return new ValidationResult();
	}
	
	public ValidationResult(String errorMessage,
			View viewWhichRequestFocus)
	{
		this.errorMessage = errorMessage;
		this.viewWhichRequestFocus = viewWhichRequestFocus;
	}
	
	public Boolean isValid()
	{
		return errorMessage == null;
	}
	
	
	public void focusView()
	{
		Toast toast = Toast.makeText(viewWhichRequestFocus.getContext(), errorMessage, 
				Toast.LENGTH_LONG);
		toast.show();
		viewWhichRequestFocus.requestFocus();
	}
}
